<?php
/*
error_reporting(E_ALL);
ini_set('display_errors', '1');
*/

// An array of our built in pages
// pageName => actionName
$pages = array(
    'Home' => 'home',
    'Donate' => 'donate',
    'Contact' => 'contact'
);

session_start();

// Get the config file
include_once('./config.php');

// Get the action request, and make sure it is valid.
$action = strtolower(htmlspecialchars($_GET['action'])); 
function get_page_content() {
    global $pages;
    global $action;
    
    if (in_array($action, $pages)) {
        include_once("./includes/pages/$action.php"); 
    }
    
    else {
        include_once("./includes/pages/home.php");
    }
}

?>

<!DOCTYPE html>
<html>
    <?php include_once('./includes/head.php'); ?>
    <body>
        <div class="ContentContainer">
            <div class="Header">
                <?php include_once('includes/header.php'); ?>
            </div>
            <div class="Main">
                <div class="LeftSide">
                    <?php include_once('./includes/left_side.php'); ?>
                </div>  
                <div class="Content">
                    <?php get_page_content(); ?>
                </div>
                <div class="RightSide">
                    <?php include_once('./includes/right_side.php'); ?>
                </div>
            </div>
            <div class="Footer">
                <?php include_once('./includes/footer.php'); ?>
            </div>
        </div>
    </body>
</html>